import { Component, OnInit } from '@angular/core';
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { TemplateService } from './template.service';

import * as moment from 'moment';
import * as _ from 'lodash'

@Component({
	selector: 'app-template',
	templateUrl: './template.component.html',
	styleUrls: ['./template.component.scss'],
	providers: [TemplateService]
})
export class TemplateComponent implements OnInit {

	public templateList = [];

	public listCount = 20;

	public type = 0;

	constructor(
		private templateTemplateService: TemplateService,
		public router: Router,
		private route: ActivatedRoute,
	) {
		this.route.params.subscribe((data) => {
			console.info(data);
			this.type = parseInt(data.type);
			this.initList(this.type);
		});
	}
	initList(type) {
		this.templateList = [];
		let name = "";
		if (type === 1) {
			name = "基金合同模板";
		} else if (type === 2) {
			name = "托管协议模板";
		} else if (type === 3) {
			name = "代销协议模板";
		} else if (type === 4) {
			name = "招募说明书模板";
		}
		for (var i = 1; i <= this.listCount; i++) {
			this.templateList.push({
				name: name + i,
				user: '王强',
				time: "2017-5-3 07:28:47"
			});
		}
	}

	nav() {
		// window["$"]("#content-main-modal").modal();
		// document.getElementById("content-main-modal-iframe")['src'] = "product/img";
		// window.open("product/img");
		window['currentTitle'] = '模板详情';
		this.router.navigate(['pages/dashboard/p/img']);
		window.scrollTo(0, 0);
	}

	ngOnInit() {

		// this.templateList = this.templateTemplateService.list();
	}

}
